package yj.study;
import java.io.IOException;
import java.util.logging.Logger;
import java.util.logging.SocketHandler;
public class SocketHandlerTest {
	private SocketHandler handler= null;
	private static Logger logger = Logger.getLogger("yj.study.SocketHandler");
	public SocketHandlerTest(String host,int port){
		try{//handler从logger中获得日志信息，并将这些信息导出，可以写入文件，控制台或者server
			handler = new SocketHandler(host,port);
			logger.addHandler(handler);
			logger.info("SocketHandler 运行成功！！！");
		}catch(IOException e){
			logger.severe("请检查地址和接口是否正确！！！");
			StringBuilder sb = new StringBuilder();
			sb.append(e.toString()).append("\n");
			for(StackTraceElement elem : e.getStackTrace()){
				sb.append("\tat").append(elem).append("\n");
			}
			logger.severe(sb.toString());
		}
	}
	
	public static void main(String[] args){
		new SocketHandlerTest("localhost",8080);
	}
}
